home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programmer Power Tools
/
Programmer Power Tools.iso
/
ada
/
changesn.ada
< prev
next >
Wrap
Text File
|
1988-03-25
|
2KB
|
50 lines
-- CHANGESN.ADA Ver. 1.00 25-MAR-1988
-- Copyright 1988 John J. Herro
-- Software Innovations Technology
-- 1083 Mandarin Drive NE, Palm Bay, FL 32905-4706 (407)951-0233
--
-- Used to change the serial number in ADA-TUTR.DAT after registering. When
-- compiling this program on any computer other than a PC running Artek Ada
-- (tm, Artek Corp.), compile NON-PC.ADA or VAX.ADA first.
--
with CON_IO, DIRECT_IO; use CON_IO;
-- The package CON_IO (console I/O) comes with Artek Ada. CON_IO contains
-- PUT, PUT_LINE, and NEW_LINE, similar to TEXT_IO. It also contains GET to
-- get a string (with editing capability).
procedure CHANGESN is
subtype BLOCK_SUBTYPE is STRING(1 .. 64);
package RANDOM_IO is new DIRECT_IO(BLOCK_SUBTYPE); use RANDOM_IO;
DATA_FILE : RANDOM_IO.FILE_TYPE;
BLOCK : BLOCK_SUBTYPE; -- Block read from the data file.
BLOCK_NUM : RANDOM_IO.COUNT := 58; -- Number of the current block.
PLACE : INTEGER; -- Index to search for "Serial #".
FOUND : BOOLEAN := FALSE; -- True when "Serial #" is found.
SERIAL_NUM : STRING(1 .. 5); -- The serial number, in ASCII.
LEGAL_NOTE : constant STRING(1 .. 30) := " Copyright 1988 John J. Herro ";
-- LEGAL_NOTE isn't used by the program, but it causes
-- the compiler to place this string in the .EXE file.
begin
RANDOM_IO.OPEN(DATA_FILE, MODE => INOUT_FILE, NAME => "ADA-TUTR.DAT");
while not FOUND loop
BLOCK_NUM := BLOCK_NUM + 1;
READ(FILE => DATA_FILE, ITEM => BLOCK, FROM => BLOCK_NUM);
PLACE := 0;
while not FOUND and PLACE <= 50 loop
PLACE := PLACE + 1;
FOUND := BLOCK(PLACE .. PLACE + 7) = "Serial #";
end loop;
end loop;
SERIAL_NUM := BLOCK(PLACE + 10 .. PLACE + 14);
PUT_LINE("Old serial number is " & SERIAL_NUM & ".");
PUT("New serial number: ");
GET(SERIAL_NUM);
NEW_LINE;
BLOCK(PLACE + 10 .. PLACE + 14) := SERIAL_NUM;
WRITE(FILE => DATA_FILE, ITEM => BLOCK, TO => BLOCK_NUM);
CLOSE(DATA_FILE);
PUT_LINE("Serial number changed.");
exception
when RANDOM_IO.NAME_ERROR =>
PUT_LINE("I'm sorry. The file ADA-TUTR.DAT seems to be missing.");
end CHANGESN;